/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class PalabraDAOImpl implements orm.dao.PalabraDAO {
	public Palabra loadPalabraByORMID(int pal_id) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return loadPalabraByORMID(session, pal_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra getPalabraByORMID(int pal_id) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return getPalabraByORMID(session, pal_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra loadPalabraByORMID(int pal_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return loadPalabraByORMID(session, pal_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra getPalabraByORMID(int pal_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return getPalabraByORMID(session, pal_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra loadPalabraByORMID(PersistentSession session, int pal_id) throws PersistentException {
		try {
			return (Palabra) session.load(orm.Palabra.class, new Integer(pal_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra getPalabraByORMID(PersistentSession session, int pal_id) throws PersistentException {
		try {
			return (Palabra) session.get(orm.Palabra.class, new Integer(pal_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra loadPalabraByORMID(PersistentSession session, int pal_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Palabra) session.load(orm.Palabra.class, new Integer(pal_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra getPalabraByORMID(PersistentSession session, int pal_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Palabra) session.get(orm.Palabra.class, new Integer(pal_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra[] listPalabraByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return listPalabraByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra[] listPalabraByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return listPalabraByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra[] listPalabraByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra as Palabra");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Palabra[]) list.toArray(new Palabra[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra[] listPalabraByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra as Palabra");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Palabra[]) list.toArray(new Palabra[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra loadPalabraByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return loadPalabraByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra loadPalabraByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return loadPalabraByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra loadPalabraByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Palabra[] palabras = listPalabraByQuery(session, condition, orderBy);
		if (palabras != null && palabras.length > 0)
			return palabras[0];
		else
			return null;
	}
	
	public Palabra loadPalabraByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Palabra[] palabras = listPalabraByQuery(session, condition, orderBy, lockMode);
		if (palabras != null && palabras.length > 0)
			return palabras[0];
		else
			return null;
	}
	
	public static java.util.Iterator iteratePalabraByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return iteratePalabraByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iteratePalabraByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DiagnosticoPersistentManager.instance().getSession();
			return iteratePalabraByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iteratePalabraByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra as Palabra");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iteratePalabraByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Palabra as Palabra");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra createPalabra() {
		return new orm.Palabra();
	}
	
	public boolean save(orm.Palabra palabra) throws PersistentException {
		try {
			orm.DiagnosticoPersistentManager.instance().saveObject(palabra);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Palabra palabra) throws PersistentException {
		try {
			orm.DiagnosticoPersistentManager.instance().deleteObject(palabra);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Palabra palabra) throws PersistentException {
		try {
			orm.DiagnosticoPersistentManager.instance().getSession().refresh(palabra);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Palabra palabra) throws PersistentException {
		try {
			orm.DiagnosticoPersistentManager.instance().getSession().evict(palabra);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Palabra loadPalabraByCriteria(PalabraCriteria palabraCriteria) {
		Palabra[] palabras = listPalabraByCriteria(palabraCriteria);
		if(palabras == null || palabras.length == 0) {
			return null;
		}
		return palabras[0];
	}
	
	public Palabra[] listPalabraByCriteria(PalabraCriteria palabraCriteria) {
		return palabraCriteria.listPalabra();
	}
}
